const StyleLintPlugin = require('stylelint-webpack-plugin')
const path = require('path')
const lessThemePath = path.resolve(
  __dirname,
  './src/assets/less/vantChange.less'
)
module.exports = {
  devServer: {
    proxy: {
      '/api': {
        //此处要与 /services/api.js 中的 API_PROXY_PREFIX 值保持一致
        target: process.env.VUE_APP_API_BASE_URL,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  },
  configureWebpack: {
    plugins: [
      new StyleLintPlugin({
        files: ['src/**/*.{html,htm,vue,css,sass,scss,less}'],
        fix: false,
        cache: false,
        emitErrors: true,
        failOnError: false
      })
    ]
  },
  css: {
    loaderOptions: {
      less: {
        // 若 less-loader 版本小于 6.0，请移除 lessOptions 这一级，直接配置选项。
        lessOptions: {
          modifyVars: {
            // 或者可以通过 less 文件覆盖（文件路径为绝对路径）
            hack: `true; @import "${lessThemePath}";`
          }
        }
      },
      postcss: {
        plugins: [
          require('postcss-pxtorem')({
            rootValue: 37.5,
            propList: ['*']
            // selectorBlackList: ['van-']
          })
        ]
      }
    }
  }
}
